package com.x.aoki.payment.hystrix.controller;

import com.x.aoki.payment.hystrix.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author caoy
 * @date 2025-02-17 15:32:48
 */
@RestController
@Slf4j
public class PaymentController {

    @Resource
    private PaymentService paymentService;

    @Value("${server.port}")
    private String serverPort;

    @GetMapping("payment/hystrix/ok/{id}")
    public String paymentInfo_OK(@PathVariable("id") Integer id) {
        String info_ok = paymentService.paymentInfo_OK(id);
        log.info("result: %s", info_ok);
        return info_ok;
    }

    @GetMapping("payment/hystrix/timeout/{id}")
    public String paymentInfo_Timeout(@PathVariable("id") Integer id) {
        String info_timeout = paymentService.paymentInfo_Timeout(id);
        log.info("result: %s", info_timeout);
        return info_timeout;
    }

    @GetMapping("payment/hystrix/circuitbreaker/timeout/{id}")
    public String paymentCircuitBreaker(@PathVariable("id") Integer id) {
        return paymentService.paymentCircuitBreaker(id);
    }

}
